<?php

use yii\helpers\Url;
use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model app\models\Task */

$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => '任务管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="task-view" style="width: 300px; margin:0 auto;">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('修改', ['update', 'month' => $month], ['class' => 'btn btn-primary']) ?>
    </p>


    <table class="layui-table">
        <tr style="background:#d9534f;color:#fff;">
            <td colspan="2" style="text-align: center;">
                <select class="layui-select" onchange="window.select_month(this.value)">
                    <?php foreach ($month_options as $p) { ?>
                        <option value="<?= $p['name'] ?>" <?= $p['selected'] ? 'selected="selected"' : '' ?>><?= $p['name'] ?></option>
                    <?php } ?>
                </select>
            </td>
        </tr>
        <tr style="background:#ccc;">
            <td style="text-align: right;">姓名</td>
            <td><?= $t->task_num  ?>月任务数量</td>
        </tr>
        <?php foreach ($tasks as $t) { ?>
            <tr class="task_tr">
                <td style="text-align: right;"><?= $t->showname ?>：</td>
                <td><?= $t->task_num  ?></td>
            </tr>
        <?php } ?>
    </table>
</div>

<script type="text/javascript">
    window.select_month = function(month_value) {
        window.location.href = '<?= Url::toRoute('task/view') ?>&month=' + month_value;
    }
</script>